#!/bin/bash

MODULE=$1
TIME=`date "+%Y%m%d%H%M"`
#获取git中源代码的版本号
GIT_REVISION=`git log -1 --pretty=format:"%h"`
IMAGE_NAME=hub.monkeywood.com/microservice/${MODULE}:${TIME}_${GIT_REVISION}

echo IMAGE_NAME

cd ${MODULE}

docker build -t ${IMAGE_NAME} .
cd -

docker push ${IMAGE_NAME}

#将新镜像名写入临时文件IMAGE_NAME中
echo "${IMAGE_NAME}" > IMAGE_NAME